<extend name="template/base_index" />


<block name="area_header">
	<link rel="stylesheet" type="text/css" media="all" href="__CSS__/wxshop.css">
	<link type="text/css" rel="stylesheet" src="__CDN__/jquery-uploadify/3.2.1/uploadify.css" />
	<script type="text/javascript" src="__CDN__/jquery-uploadify/3.2.1/jquery.uploadify.min.js"></script>
	<link rel="stylesheet" type="text/css" media="all" href="__CDN__/jquery-datetimepicker/jquery.datetimepicker.css">
	<script type="text/javascript" src="__CDN__/jquery-datetimepicker/jquery.datetimepicker.js"></script>
	<link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/select2.min.css" />
	<script type="text/javascript" src="__CDN__/select2/4.0.0/js/select2.full.js"></script>
	<script type="text/javascript" src="__CDN__/select2/4.0.0/js/i18n/zh-CN.js"></script>
</block>

<block name="area_body">
	{:W('Menus/topbar')}
	<div class="admin-main container-fluid">
		{:W('Menus/left')}
		<div class="admin-main-content">
			{:W('Menus/breadcrumb')}
			<!-- 带验证 form -->
			<form class="form-horizontal well validateForm">
				<input type="hidden" name="level" value="{$level}" />
				<input type="hidden" name="parent" value="{$parent}" />
				<input type="hidden" name="lang" value="{$lang}" />
				<input type="hidden" name="icon" id="icon" value="0" />
				<fieldset>
					<legend>
						类目添加
					</legend>
					<div class="form-group">
						<label class="col-md-2 col-lg-2 control-label">&nbsp;</label>
						<div class="col-lg-3 col-md-3">
							<a target-form="validateForm" class="ajax-post btn btn-primary btn-sm" href="{:U('Admin/Category/add')}" autofocus="autofocus"><i class="fa fa-save"></i> {:L('BTN_SAVE')}</a>
							<a class="btn btn-default btn-sm" href="{:U('Admin/Category/index',array('parent'=>$parent,'preparent'=>$preparent))}"><i class="fa fa-times-circle"></i> {:L('BTN_CANCEL')}</a>
						</div>
					</div>
					<div class="form-group">
						<label for="inputname" class="col-md-2 col-lg-2 control-label">所属类目</label>
						<div class="col-md-3 col-lg-3">
							<select name="cate" id="cate" style="width: 360px;">
							<volist name="cate_list" id="cate">
								<if condition="$cate['level'] lt 3">
								<option value="{$cate.id}">
									{:str_repeat("--",$cate['level']-1)}
									{$cate.name}
								</option>
								</if>
							</volist></select>
							<div class="help-block">(选择所属类目)</div>
						</div>
					</div>
					<div class="form-group">
						<label for="inputname" class="col-md-2 col-lg-2 control-label">类目名称[默认]</label>
						<div class="col-md-3 col-lg-3">
							<input type="text" class="required form-control input-sm" name="name" id="inputname" placeholder="请输入类目名称,请不要超过30个字">
							<div class="help-block">(请输入类目名称,不要超过30个字)</div>
						</div>
					</div>
					<volist name="lang_list" id="vo" >
						<div class="form-group">
							<label for="inputname" class="col-md-2 col-lg-2 control-label">类目名称[{$vo['name']}]</label>
							<div class="col-md-3 col-lg-3">
								<input type="hidden" value="{$vo['value']}" class="required form-control input-sm" name="cate_lang[]" >
								<input type="text" class="required form-control input-sm" name="cate_lang_{:md5($vo['value'])}" placeholder="请输入类目名称,请不要超过30个字">
								<div class="help-block">(请输入类目名称,不要超过30个字)</div>
							</div>
						</div>
					</volist>

					<div class="form-group hide">
						<label class="col-md-2 col-lg-2 control-label">税号</label>
						<div class="col-md-3 col-lg-3">
							<input type="text" class="required form-control input-sm" name="code" placeholder="请输入税号">
							<div class="help-block">(请输入税号)</div>
						</div>
					</div>
					<div class="form-group hide">
						<label class="col-md-2 col-lg-2 control-label">范围</label>
						<div class="col-md-3 col-lg-3">
							<input type="text" class="required form-control input-sm" name="scope" placeholder="请输入物品范围">
							<div class="help-block">(请输入物品范围)</div>
						</div>
					</div>
					<div class="form-group hide">
						<label class="col-md-2 col-lg-2 control-label">税率</label>
						<div class="col-md-3 col-lg-3">
							<input type="text" class="required form-control input-sm" name="taxrate" placeholder="请输入税率">
							<div class="help-block">(请输入税率)</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 col-lg-2 control-label">显示顺序</label>
						<div class="col-md-3 col-lg-3">
							<input type="number" class="required form-control input-sm" name="display_order" placeholder="请输入显示顺序" value="0">
							<div class="help-block">(显示循序，序号越大显示越前，默认0)</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-2 col-lg-2 control-label">类目图标</label>
						<div class="col-md-3 col-lg-3">
							<div class="col-lg-3 col-md-3">
								上传类目图标
								<!-- 图片选择DOM结构 -->
								<div class="wxuploaderimg icon clearfix <notempty name="cate.icon">checked</notempty>"  data-maxitems="1">
								<div class="img-preview clearfix" >
									<notempty name="cate.icon">
										<div class="pull-left clearfix img-item">
											<img src="{:getImgUrl($cate['icon'],120)}" data-imageid="{$vo.main_img}"/>
											<div class="edit_pic_wrp"><a href="javascript:;" class="fa fa-lg fa-trash js_delete"></a></div>
										</div>
									</notempty>
								</div>
								<div class="add">
									<i class="fa fa-plus"></i>
								</div>
							</div>
							<!-- 图片选择DOM结构 -->
						</div>
					</div>
		</div>


		<div class="form-group">
			<label class="col-md-2 col-lg-2 control-label">&nbsp;</label>
			<div class="col-lg-3 col-md-3">
				<a target-form="validateForm" class="ajax-post btn btn-primary btn-sm" onclick="return check();" id="js_submit" href="{:U('Admin/Category/add')}" autofocus="autofocus"><i class="fa fa-save"></i> {:L('BTN_SAVE')}</a>
				<a class="btn btn-default btn-sm" href="{:U('Admin/Category/index',array('parent'=>$parent,'preparent'=>$preparent))}"><i class="fa fa-times-circle"></i> {:L('BTN_CANCEL')}</a>
			</div>
		</div>
		</fieldset>
		</form>
		<!-- form -->
		<include file="template/wxpicture"/>
	</div>
	<!-- END admin-main-content -->
	</div>
	<!-- END admin-main-->
</block>

<block name="area_footer">
	<script type="text/javascript">
		function check(){
			var icon = $(".icon .img-preview img").attr("data-imageid");
			$("#icon").val(icon);
			return true;
		}
		$(function() {

            $("#cate").select2({
                placeholder: "输入类目名称搜索",
                language: "zh-CN"});

			//图片上传
			wxuploadimg.init({cont:".wxuploaderimg"});
			//
			$(".js_frm_gp_buylimit input[type=radio]").click(function(){

				if($(this).val() == 1){
					$(".js_frm_gp_buylimit input[type=text]").removeClass("hidden");
				}else{
					$(".js_frm_gp_buylimit input[type=text]").addClass("hidden");
				}
			});
			$(".js_frm_gp_buylimit input[type=radio][value=0]").click(function(){
				$(".js_frm_gp_buylimit input[type=text]").attr('value',0);
				$(".js_frm_gp_buylimit input[type=text]").val(0);
			});
			$(".js_frm_gp_buylimit input[type=text]").change(function(){
				var tmp = $(this).val();
				$(this).attr("value",tmp);
			});
			$(".js_delete:first").click(function(){
				$(".main_img .img-preview img").attr("data-imageid","");
				$("#main_img").attr("value","");
				$("#main_img").val("");
			});


		})
	</script>
</block>